package me.zhengjie.modules.workflow.commad;

import org.activiti.engine.impl.cmd.NeedsActiveTaskCmd;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.activiti.engine.impl.persistence.entity.TaskEntityManagerImpl;

/**
 * 流程任务删除
 * @description: FlowToPreNodeCmd <br>
 * @date: 2021/5/12 18:06 <br>
 * @author: wangz <br>
 * @version: 1.0 <br>
 */
public class TaskDeleteCmd extends NeedsActiveTaskCmd<String> {

    public TaskDeleteCmd(String taskId){
        super(taskId);
    }

    @Override
    protected String execute(CommandContext commandContext, TaskEntity currentTask) {
        TaskEntityManagerImpl taskEntityManager = (TaskEntityManagerImpl) commandContext.getTaskEntityManager();
        ExecutionEntity executionEntity = currentTask.getExecution();
        taskEntityManager.deleteTask(currentTask, "reject", false, false);
        return executionEntity.getId();
    }


}
